<?php
if(!empty($_POST) AND !isset($_POST['Entry'])){}
$result = RequestData('verteidigung');
$science = RequestData('forschung');
$ressource = RequestData('resource');
?>

<table class="buildings" style="table-layout: fixed; width: 720px;">
	<colgroup>
		<col style="width:115px;">
		<col style="width:auto;">
		<col style="width:100px">
	</colgroup>
	<thead>
		<td>Verteidigung</td>
	</thead>
	<?php
		$con = Connect();
		$check = mysql_query("SELECT * FROM verteidigung_build");
		while($object = mysql_fetch_object($check))
		{
			if($science['DefEntwicklung'] >= $object->DefEntwicklung)
			{
				echo '<tr><th><img src="../Game/template/Images/verteidigung/'.$object->Name.'.png"></th>';
				echo '<th><p>'.$object->Name.'['.$result[$object->Name].']</p><p>'.$object->Description.'</p>';
				echo '<p>Zeit: '.$object->Time.'</p><p>Ben&ouml;tigt: ';
				if($science['Laser'] < $object->Laser)
				{
					echo '<b style="color:#FF0000;"> Laser-Technik Stufe '.$object->Laser.'</b>,'; 
					$lock[1] = true;
				}else{
					echo '<b style="color:#00FF00;"> Laser-Technik Stufe '.$object->Laser.'</b>,'; 
				}
				if($science['Munition'] < $object->Munition)
				{
					echo '<b style="color:#FF0000;"> Munitions Stufe '.$object->Munition.'</b>,'; 
					$lock[2] = true;
				}else{
					echo '<b style="color:#00FF00;"> Munitions Stufe '.$object->Munition.'</b>,'; 
				}
				if($science['Panzer'] < $object->Panzer)
				{
					echo '<b style="color:#FF0000;"> Panzerungs Stufe '.$object->Panzer.'</b></p>'; 
					$lock[3] = true;
				}else{
					echo '<b style="color:#00FF00;"> Panzerungs Stufe '.$object->Panzer.'</b></p>'; 
				}
				echo '<p>Ressourcen: ';
				if($ressource['Credits'] < $object->Credits)
				{
					echo '<b style="color:#FF0000;">'.$object->Credits.' Credits</b>, ';
					$lock[4] = true;
				}else{
					echo '<b style="color:#00FF00;">'.$object->Credits.' Credits</b>, ';
				}
				if($ressource['Titan'] < $object->Titan)
				{
					echo '<b style="color:#FF0000;">'.$object->Titan.' Titan</b>, ';
					$lock[5] = true;
				}else{
					echo '<b style="color:#00FF00;">'.$object->Titan.' Titan</b>, ';
				}
				if($ressource['Oel'] < $object->Oel)
				{
					echo '<b style="color:#FF0000;">'.$object->Oel.' &Ouml;l</b>';
					$lock[6] = true;
				}else{
					echo '<b style="color:#00FF00;">'.$object->Oel.' &Ouml;l</b>';
				}
				echo '<th><p>Einheiten: </p><p><input type="number" name="'.$object->Name.'" value="0" min="0" max="50" style="width:80px;" ';
				if($lock[0] == true || $lock[1] == true || $lock[2] == true || $lock[3] == true || $lock[4] == true || $lock[5] == true || $lock[6] == true) echo 'disabled';
				echo '></p><br><p><input type="submit" name="defense"></p></th></tr>';
			}
		}
		Close($con);
	?>
</table>